Skip to content

feat: add debug_info method to TypeScript Parser#80

Open
farooqu wants to merge 3 commits intocooklang:mainfrom
farooqu:debug-api
Open

feat: add debug_info method to TypeScript Parser#80
farooqu wants to merge 3 commits intocooklang:mainfrom
farooqu:debug-api

Conversation

@farooqu
Copy link
Contributor

@farooqu farooqu commented Nov 11, 2025

Adds debug_info() method to Parser class that returns a DebugInfo object containing version, extensions, load_units, ast, events, full_recipe, metadata, and report.

Addresses #55.

Changes

  • Added DebugInfo struct
  • Added Parser.debug_info() method
  • Added debug mode to playground
  • Added DEBUG.md documentation
  • Added debug.test.ts tests
  • Fixed YAML frontmatter handling in build_ast()

farooqu and others added 3 commits November 11, 2025 14:58
- Add DebugInfo struct containing version, extensions, load_units, ast, events, full_recipe, metadata, and report
- Add Parser.debug_info() method to generate all debug info on-demand in a single call
- Export DebugInfo type from TypeScript library for type safety
- Add comprehensive DEBUG.md documentation with usage examples and issue reporting templates
- Add test coverage for debug_info functionality
- Include DEBUG.md in package.json files for npm distribution

Addresses issue cooklang#55: make Rust debug functionality available in TypeScript without storing in memory

Amp-Thread-ID: https://ampcode.com/threads/T-5964db91-ab54-40b7-84b9-42c64969e1cd
Co-authored-by: Amp <amp@ampcode.com>
- Add 'Debug info (for reporting)' option to parser select dropdown
- Implement debug_info() call and formatted output display
- Show version, extensions, load_units config prominently for issue reporting
- Include copyable debug info section with AST, events, recipe, and metadata
- Hide JSON and servings controls when in debug mode
- Display parser diagnostics in errors panel
- Replace todo!() with proper handling for YAMLFrontMatter events
- Add test cases for debug_info with metadata
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 11, 2025

cooklang-playground

npm i https://pkg.pr.new/cooklang/cooklang-rs/@cooklang/cooklang-ts@80

commit: c89e3d8

match event {
Event::YAMLFrontMatter(_) => todo!(),
Event::Metadata { key, value } => blocks.push(Block::Metadata { key, value }),
match event {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like unrelated change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, it isn't completely related. I was testing the implementation in the playground using benches/frontmatter_test_recipe.cook to see the debug output and it was constantly failing due to this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's at least fix formatting and add TODO as comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants